package edu.spec.chenli.Struts2;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class LoginRegistAction extends ActionSupport {
    private String username;
    private String password;
    private String tip;
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    public String getTip() {
        return tip;
    }

    public void setTip(String tip) {
        this.tip = tip;
    }

   public String regist()throws Exception{
       ActionContext.getContext().getSession().put("user",getUsername());
       setTip("恭喜你,"+getUsername()+",你已经注册成功");
       return SUCCESS;
   }
   public String execute()throws  Exception{
        if(getUsername().equals("abc")&& getPassword().equals("123")){
            ActionContext.getContext().getSession().put("user",getUsername());
            setTip("欢迎,"+getUsername()+",你已经成功登录");
            return  SUCCESS;
        }
        return  ERROR;
   }
}
